Convert a list into a nested dictionary of keys¶
Convert a list into a nested dictionary of keys.
L = [1, 2, 3, 4]
D = current = {}
for name in L:
current[name] = {}
current = current[name]
print(D)
Output:
{1: {2: {3: {4: {}}}}}